<?php
require_once('config.php');
require_once('functions.php');
require_once('header,allow.php');
$params = $_REQUEST['params'];
if(!$_REQUEST['tn_r']){
    $_REQUEST['tn_r'] = $params['tn_r'];
}
$time = isset($_GET['time'])?$_GET['time']:$_GET['t'];
if(!$time){
    $_GET['time'] =  $params['time'];
}
sleep(1);
$expect = createRand();

require_once dirname(__FILE__).'/TnCode.class.php';
$tn  = new TnCode();


if($tn->check()){
    $time  = time();
    $result = array(
        'rect'=>'ok',
        'codeTime'=>$time,
        'pinCode'=>md5('iLove'.$time.'qilaiwan')
    );
    echo json_encode($result);
}else{
    $result = array(
        'rect'=>'error',
       // 'expect'=>$expect[0],
        //'expectTime'=>$expect[1],
        'tn_r'=>$_REQUEST['tn_r']
    );
    echo json_encode($result);
}

?>
